<?php
/**
 * 生成物品和材料ID的关系
 */
echo '<pre>';

$list = C('item/item_list');
$itemList = array();
foreach ($list as $itemId => $value) {
	$itemList[$itemId] = $value['title'];
}

// 物品参数ID关联
$mat_type_list = array(
	'cook', //食品
	'drink', //饮料
	'furniture', //家具
//	'finery', //服饰
);
include($G['path_inc'].'conf/build/making.cfg.php');
foreach ($mat_type_list as $name) {
	$matList = array();
	include($G['path_inc'].'conf/making/'.$name.'_param.cfg.php');
	foreach ($G[$name.'_sec_mat_item'] as $k=>$v) {
		$matList[$k] = $v['title'];
	}
	$matList = $matList;
	
	$itemMat = array();
	foreach ($G[$name.'_param_list'] as $matId=>$v) {
		$itemId = array_search($v, $itemList);
		if ($itemId) {
			$itemMat[$itemId] = $matId;
		}
		echo $v, ' ', $matId, "\n";
	}
	ksort($itemMat);
	$str = 'return '.var_export($itemMat, true);
	$filename = $G['path_inc'].'conf/making/'.$name.'_item_mat.cfg.php';
	writefile($filename, $str, 'php');
	echo $filename, "\n";
}


